pulse-dashboard
Version:
A Next.js Dashboard application for real-time monitoring and historical analysis of Playwright test executions, based on playwright-pulse-report. This component provides the UI for visualizing Playwright test results and can be run as a standalone CLI too
1 lines • 42.8 kB
JavaScript
(()=>{var e={};e.id=847,e.ids=[847],e.modules={677:(e,s,t)=>{Promise.resolve().then(t.bind(t,71037))},3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},17947:(e,s,t)=>{"use strict";t.d(s,{TestDetailsClientPage:()=>r});let r=(0,t(12907).registerClientReference)(function(){throw Error("Attempted to call TestDetailsClientPage() from the server but TestDetailsClientPage is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/Users/administrator/playwright-pulse-dashboard/src/components/pulse-dashboard/TestDetailsClientPage.tsx","TestDetailsClientPage")},19121:e=>{"use strict";e.exports=require("next/dist/server/app-render/action-async-storage.external.js")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:e=>{"use strict";e.exports=require("path")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},71037:(e,s,t)=>{"use strict";t.d(s,{TestDetailsClientPage:()=>eW});var r=t(60687),a=t(65773),n=t(48661),l=t(44493),i=t(29523),o=t(15079),d=t(43210),c=t(70569),u=t(11273),h=t(9510),m=t(98599),x=t(96963),p=t(14163),f=t(13495),g=t(65551),j=t(43),v="rovingFocusGroup.onEntryFocus",b={bubbles:!1,cancelable:!0},y="RovingFocusGroup",[N,w,k]=(0,h.N)(y),[A,T]=(0,u.A)(y,[k]),[M,C]=A(y),F=d.forwardRef((e,s)=>(0,r.jsx)(N.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,r.jsx)(N.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,r.jsx)(S,{...e,ref:s})})}));F.displayName=y;var S=d.forwardRef((e,s)=>{let{__scopeRovingFocusGroup:t,orientation:a,loop:n=!1,dir:l,currentTabStopId:i,defaultCurrentTabStopId:o,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:x=!1,...y}=e,N=d.useRef(null),k=(0,m.s)(s,N),A=(0,j.jH)(l),[T=null,C]=(0,g.i)({prop:i,defaultProp:o,onChange:u}),[F,S]=d.useState(!1),D=(0,f.c)(h),L=w(t),E=d.useRef(!1),[I,R]=d.useState(0);return d.useEffect(()=>{let e=N.current;if(e)return e.addEventListener(v,D),()=>e.removeEventListener(v,D)},[D]),(0,r.jsx)(M,{scope:t,orientation:a,dir:A,loop:n,currentTabStopId:T,onItemFocus:d.useCallback(e=>C(e),[C]),onItemShiftTab:d.useCallback(()=>S(!0),[]),onFocusableItemAdd:d.useCallback(()=>R(e=>e+1),[]),onFocusableItemRemove:d.useCallback(()=>R(e=>e-1),[]),children:(0,r.jsx)(p.sG.div,{tabIndex:F||0===I?-1:0,"data-orientation":a,...y,ref:k,style:{outline:"none",...e.style},onMouseDown:(0,c.m)(e.onMouseDown,()=>{E.current=!0}),onFocus:(0,c.m)(e.onFocus,e=>{let s=!E.current;if(e.target===e.currentTarget&&s&&!F){let s=new CustomEvent(v,b);if(e.currentTarget.dispatchEvent(s),!s.defaultPrevented){let e=L().filter(e=>e.focusable);P([e.find(e=>e.active),e.find(e=>e.id===T),...e].filter(Boolean).map(e=>e.ref.current),x)}}E.current=!1}),onBlur:(0,c.m)(e.onBlur,()=>S(!1))})})}),D="RovingFocusGroupItem",L=d.forwardRef((e,s)=>{let{__scopeRovingFocusGroup:t,focusable:a=!0,active:n=!1,tabStopId:l,...i}=e,o=(0,x.B)(),u=l||o,h=C(D,t),m=h.currentTabStopId===u,f=w(t),{onFocusableItemAdd:g,onFocusableItemRemove:j}=h;return d.useEffect(()=>{if(a)return g(),()=>j()},[a,g,j]),(0,r.jsx)(N.ItemSlot,{scope:t,id:u,focusable:a,active:n,children:(0,r.jsx)(p.sG.span,{tabIndex:m?0:-1,"data-orientation":h.orientation,...i,ref:s,onMouseDown:(0,c.m)(e.onMouseDown,e=>{a?h.onItemFocus(u):e.preventDefault()}),onFocus:(0,c.m)(e.onFocus,()=>h.onItemFocus(u)),onKeyDown:(0,c.m)(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey){h.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let s=function(e,s,t){var r;let a=(r=e.key,"rtl"!==t?r:"ArrowLeft"===r?"ArrowRight":"ArrowRight"===r?"ArrowLeft":r);if(!("vertical"===s&&["ArrowLeft","ArrowRight"].includes(a))&&!("horizontal"===s&&["ArrowUp","ArrowDown"].includes(a)))return E[a]}(e,h.orientation,h.dir);if(void 0!==s){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let t=f().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===s)t.reverse();else if("prev"===s||"next"===s){"prev"===s&&t.reverse();let r=t.indexOf(e.currentTarget);t=h.loop?function(e,s){return e.map((t,r)=>e[(s+r)%e.length])}(t,r+1):t.slice(r+1)}setTimeout(()=>P(t))}})})})});L.displayName=D;var E={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function P(e,s=!1){let t=document.activeElement;for(let r of e)if(r===t||(r.focus({preventScroll:s}),document.activeElement!==t))return}var I=t(46059),R="Tabs",[$,_]=(0,u.A)(R,[T]),z=T(),[H,O]=$(R),q=d.forwardRef((e,s)=>{let{__scopeTabs:t,value:a,onValueChange:n,defaultValue:l,orientation:i="horizontal",dir:o,activationMode:d="automatic",...c}=e,u=(0,j.jH)(o),[h,m]=(0,g.i)({prop:a,onChange:n,defaultProp:l});return(0,r.jsx)(H,{scope:t,baseId:(0,x.B)(),value:h,onValueChange:m,orientation:i,dir:u,activationMode:d,children:(0,r.jsx)(p.sG.div,{dir:u,"data-orientation":i,...c,ref:s})})});q.displayName=R;var V="TabsList",G=d.forwardRef((e,s)=>{let{__scopeTabs:t,loop:a=!0,...n}=e,l=O(V,t),i=z(t);return(0,r.jsx)(F,{asChild:!0,...i,orientation:l.orientation,dir:l.dir,loop:a,children:(0,r.jsx)(p.sG.div,{role:"tablist","aria-orientation":l.orientation,...n,ref:s})})});G.displayName=V;var X="TabsTrigger",K=d.forwardRef((e,s)=>{let{__scopeTabs:t,value:a,disabled:n=!1,...l}=e,i=O(X,t),o=z(t),d=U(i.baseId,a),u=Z(i.baseId,a),h=a===i.value;return(0,r.jsx)(L,{asChild:!0,...o,focusable:!n,active:h,children:(0,r.jsx)(p.sG.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":u,"data-state":h?"active":"inactive","data-disabled":n?"":void 0,disabled:n,id:d,...l,ref:s,onMouseDown:(0,c.m)(e.onMouseDown,e=>{n||0!==e.button||!1!==e.ctrlKey?e.preventDefault():i.onValueChange(a)}),onKeyDown:(0,c.m)(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&i.onValueChange(a)}),onFocus:(0,c.m)(e.onFocus,()=>{let e="manual"!==i.activationMode;h||n||!e||i.onValueChange(a)})})})});K.displayName=X;var B="TabsContent",W=d.forwardRef((e,s)=>{let{__scopeTabs:t,value:a,forceMount:n,children:l,...i}=e,o=O(B,t),c=U(o.baseId,a),u=Z(o.baseId,a),h=a===o.value,m=d.useRef(h);return d.useEffect(()=>{let e=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,r.jsx)(I.C,{present:n||h,children:({present:t})=>(0,r.jsx)(p.sG.div,{"data-state":h?"active":"inactive","data-orientation":o.orientation,role:"tabpanel","aria-labelledby":c,hidden:!t,id:u,tabIndex:0,...i,ref:s,style:{...e.style,animationDuration:m.current?"0s":void 0},children:t&&l})})});function U(e,s){return`${e}-trigger-${s}`}function Z(e,s){return`${e}-content-${s}`}W.displayName=B;var J=t(4780);let Q=d.forwardRef(({className:e,...s},t)=>(0,r.jsx)(G,{ref:t,className:(0,J.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...s}));Q.displayName=G.displayName;let Y=d.forwardRef(({className:e,...s},t)=>(0,r.jsx)(K,{ref:t,className:(0,J.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...s}));Y.displayName=K.displayName;let ee=d.forwardRef(({className:e,...s},t)=>(0,r.jsx)(W,{ref:t,className:(0,J.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...s}));ee.displayName=W.displayName;var es=t(85726),et=t(91821),er=t(42692),ea=t(82614);let en=(0,ea.A)("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);var el=t(38765),ei=t(97025),eo=t(72963),ed=t(15036),ec=t(99196);let eu=(0,ea.A)("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]),eh=(0,ea.A)("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),em=(0,ea.A)("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);var ex=t(50069);let ep=(0,ea.A)("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),ef=(0,ea.A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),eg=(0,ea.A)("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]),ej=(0,ea.A)("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),ev=(0,ea.A)("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]),eb=(0,ea.A)("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),ey=(0,ea.A)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);var eN=t(36260);let ew=(0,ea.A)("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]),ek=(0,ea.A)("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]),eA=(0,ea.A)("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);var eT=t(30474),eM=t(96834),eC=t(70137);let eF=(0,ea.A)("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);function eS({status:e}){switch("string"==typeof e?e.toLowerCase():""){case"passed":return(0,r.jsx)(el.A,{className:"h-4 w-4 text-green-500 flex-shrink-0"});case"failed":return(0,r.jsx)(ei.A,{className:"h-4 w-4 text-destructive flex-shrink-0"});case"skipped":return(0,r.jsx)(eo.A,{className:"h-4 w-4 text-accent flex-shrink-0"});case"timedout":return(0,r.jsx)(ed.A,{className:"h-4 w-4 text-destructive flex-shrink-0"});case"pending":return(0,r.jsx)(ed.A,{className:"h-4 w-4 text-primary animate-pulse flex-shrink-0"});default:return(0,r.jsx)(ec.A,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"})}}function eD({step:e,level:s=0}){var t;let a=e.steps&&e.steps.length>0,n=(0,r.jsxs)("div",{className:`flex flex-col space-y-2 ${s>0?"pl-4 border-l border-muted ml-2":""}`,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between space-x-2",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,r.jsx)(eS,{status:e.status}),(0,r.jsx)("span",{className:"text-sm font-medium text-foreground truncate",title:e.title,children:e.title}),e.isHook&&(0,r.jsx)(eM.E,{variant:"outline",className:"text-xs px-1.5 py-0.5",children:e.hookType||"hook"})]}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:(t=e.duration)<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`})]}),e.codeLocation&&(0,r.jsxs)("div",{className:"flex items-center text-xs text-muted-foreground space-x-1 pl-6",children:[(0,r.jsx)(eF,{className:"h-3 w-3"}),(0,r.jsx)("span",{children:e.codeLocation})]}),e.errorMessage&&(0,r.jsxs)("div",{className:"pl-6 mt-1",children:[(0,r.jsx)("p",{className:"text-xs font-semibold text-destructive mb-0.5",children:"Error:"}),(0,r.jsx)("pre",{className:"bg-destructive/10 text-xs p-2 rounded-md whitespace-pre-wrap break-all font-code",children:(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,J.cA)(e.errorMessage)}})})]})]});return a?(0,r.jsx)(eC.nD,{type:"single",collapsible:!0,className:"w-full py-1",children:(0,r.jsxs)(eC.As,{value:`step-${e.id}`,className:"border-none",children:[(0,r.jsx)(eC.$m,{className:"p-1 hover:no-underline hover:bg-muted/50 rounded-md text-left [&[data-state=open]>svg]:rotate-90",children:n}),(0,r.jsx)(eC.ub,{className:"pt-0 pb-0",children:(0,r.jsx)("div",{className:"mt-1",children:e.steps.map(e=>(0,r.jsx)(eD,{step:e,level:s+1},e.id))})})]})}):(0,r.jsx)("div",{className:"py-2 px-1 hover:bg-muted/50 rounded-md",children:n})}var eL=t(6475);let eE=(0,eL.createServerReference)("003795f4a9ea48f4064d3202c72700337341fad304",eL.callServer,void 0,eL.findSourceMapURL,"getRawHistoricalReports");var eP=t(48482),eI=t(61678),eR=t(85168),e$=t(27747),e_=t(9920),ez=t(38246),eH=t(57359),eO=t(50326);let eq=e=>{let{cx:s,cy:t,payload:a}=e;if(!s||!t||!a)return null;let n="hsl(var(--muted-foreground))";return"passed"===a.status?n="hsl(var(--chart-3))":"failed"===a.status||"timedOut"===a.status?n="hsl(var(--destructive))":"skipped"===a.status&&(n="hsl(var(--accent))"),(0,r.jsx)("circle",{cx:s,cy:t,r:5,fill:n,stroke:"hsl(var(--card))",strokeWidth:1})},eV=({active:e,payload:s,label:t})=>{if(e&&s&&s.length){let e=s[0].payload;return(0,r.jsxs)("div",{className:"bg-card p-3 border border-border rounded-md shadow-lg",children:[(0,r.jsx)("p",{className:"label text-sm font-semibold text-foreground",children:`Date: ${new Date(e.date).toLocaleString()}`}),(0,r.jsx)("p",{className:"text-xs text-foreground",children:`Duration: ${eX(e.duration)}`}),(0,r.jsx)("p",{className:"text-xs",style:{color:"passed"===e.status?"hsl(var(--chart-3))":"failed"===e.status||"timedOut"===e.status?"hsl(var(--destructive))":"hsl(var(--accent))"},children:`Status: ${e.status}`})]})}return null};function eG({status:e}){switch(e){case"passed":return(0,r.jsx)(el.A,{className:"h-6 w-6 text-[hsl(var(--chart-3))]"});case"failed":return(0,r.jsx)(ei.A,{className:"h-6 w-6 text-destructive"});case"skipped":return(0,r.jsx)(eo.A,{className:"h-6 w-6 text-[hsl(var(--accent))]"});case"timedOut":return(0,r.jsx)(ed.A,{className:"h-6 w-6 text-destructive"});case"pending":return(0,r.jsx)(ed.A,{className:"h-6 w-6 text-primary animate-pulse"});default:return(0,r.jsx)(ec.A,{className:"h-6 w-6 text-muted-foreground"})}}function eX(e){if(e<1e3)return`${e}ms`;let s=parseFloat((e/1e3).toFixed(2));if(s<60)return`${s}s`;let t=Math.floor(s/60),r=parseFloat((s%60).toFixed(2));return`${t}m ${r}s`}function eK({contentType:e}){let s=e.toLowerCase();return s.includes("html")?(0,r.jsx)(eu,{className:"h-6 w-6 text-blue-500"}):s.includes("pdf")?(0,r.jsx)(eh,{className:"h-6 w-6 text-red-500"}):s.includes("json")?(0,r.jsx)(em,{className:"h-6 w-6 text-yellow-500"}):s.includes("csv")||s.startsWith("text/plain")?(0,r.jsx)(ex.A,{className:"h-6 w-6 text-green-500"}):s.startsWith("text/")?(0,r.jsx)(eh,{className:"h-6 w-6 text-gray-500"}):(0,r.jsx)(ep,{className:"h-6 w-6 text-gray-400"})}function eB(e,s="Attachment"){return e&&"string"==typeof e&&e.split(/[/\\]/).pop()||s}function eW({testId:e}){let s=(0,a.useRouter)(),{currentRun:t,loadingCurrent:c,errorCurrent:u}=(0,n.O)(),[h,m]=(0,d.useState)(null),[x,p]=(0,d.useState)([]),[f,g]=(0,d.useState)([]),[j,v]=(0,d.useState)(!1),[b,y]=(0,d.useState)(null),N=(0,d.useRef)(null),[w,k]=(0,d.useState)(null),[A,T]=(0,d.useState)(!1),[M,C]=(0,d.useState)(null),[F,S]=(0,d.useState)(!1),[D,L]=(0,d.useState)("current"),E=(0,d.useMemo)(()=>t?.results?.find(s=>s.id===e)||null,[t,e]),P=async()=>{if(h){T(!0),k(null),C(null);try{let e=await fetch("/api/analyze-test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({testName:h.name,failureLogsAndErrors:h.errorMessage||"",codeSnippet:h.snippet||""})});if(!e.ok){let s=await e.json().catch(()=>({message:"Failed to parse error response"}));throw Error(s.message||`API request failed with status ${e.status}`)}let s=await e.json();k(s)}catch(e){console.error("Error generating AI suggestion:",e),C(e instanceof Error?e.message:"An unknown error occurred.")}finally{T(!1)}}},I=(0,d.useCallback)(async()=>{if(e&&!F&&E?.suiteName&&t?.run?.timestamp){v(!0),y(null);try{let s=(await eE()).filter(e=>e.run.timestamp!==t.run.timestamp);p(s);let r=[];s.forEach(s=>{let t=s.results.find(s=>s.id===e&&s.suiteName===E.suiteName);t&&r.push({date:s.run.timestamp,duration:t.duration,status:t.status})}),r.sort((e,s)=>new Date(s.date).getTime()-new Date(e.date).getTime()),g(r),S(!0)}catch(e){console.error("Error fetching test history:",e),y(e instanceof Error?e.message:"Failed to load test history")}finally{v(!1)}}},[e,F,E,t]),R=(0,d.useMemo)(()=>h&&Array.isArray(h.screenshots)?h.screenshots.map((e,s)=>({name:eB(e,`Screenshot ${s+1}`),path:e,contentType:"image/png","data-ai-hint":`screenshot ${s+1}`})):[],[h]),$=(0,d.useMemo)(()=>h&&Array.isArray(h.videoPath)?h.videoPath.map((e,s)=>({name:eB(e,`Video ${s+1}`),path:e,contentType:"video/mp4","data-ai-hint":`video ${s+1}`})):[],[h]),_=(0,d.useMemo)(()=>h&&"string"==typeof h.tracePath&&h.tracePath?{name:eB(h.tracePath,"trace.zip"),path:h.tracePath,contentType:"application/zip"}:null,[h]),z=(0,d.useMemo)(()=>h&&Array.isArray(h.attachments)?h.attachments.map((e,s)=>({name:e.name||eB(e.path,`Attachment ${s+1}`),path:e.path,contentType:e.contentType||"application/octet-stream","data-ai-hint":e["data-ai-hint"]})):[],[h]),H=(0,d.useMemo)(()=>z.filter(e=>e.contentType.toLowerCase().includes("html")),[z]),O=(0,d.useMemo)(()=>z.filter(e=>e.contentType.toLowerCase().includes("pdf")),[z]),V=(0,d.useMemo)(()=>z.filter(e=>e.contentType.toLowerCase().includes("json")),[z]),G=(0,d.useMemo)(()=>z.filter(e=>e.contentType.toLowerCase().startsWith("text/")||e.contentType.toLowerCase().includes("csv")),[z]),X=(0,d.useMemo)(()=>z.filter(e=>!H.includes(e)&&!O.includes(e)&&!V.includes(e)&&!G.includes(e)),[z,H,O,V,G]),K=(0,d.useMemo)(()=>R.length+$.length+ +!!_+z.length,[R,$,_,z]),B=e=>{switch(e){case"passed":return"bg-green-500";case"failed":case"timedOut":return"bg-red-500";case"skipped":return"bg-yellow-500";default:return"bg-gray-400"}},W=h?.status==="failed"||h?.status==="timedOut";if(c&&!h)return(0,r.jsxs)("div",{className:"container mx-auto py-8 space-y-6",children:[(0,r.jsx)(es.E,{className:"h-10 w-48 mb-4 rounded-md"}),(0,r.jsxs)(l.Zp,{className:"shadow-xl rounded-lg",children:[(0,r.jsxs)(l.aR,{children:[(0,r.jsx)(es.E,{className:"h-8 w-3/4 mb-2 rounded-md"}),(0,r.jsx)(es.E,{className:"h-4 w-1/2 rounded-md"})]}),(0,r.jsxs)(l.Wu,{className:"space-y-4",children:[(0,r.jsx)(es.E,{className:"h-10 w-1/3 mb-4 rounded-md"}),(0,r.jsx)(es.E,{className:"h-40 w-full rounded-md"})]})]})]});if(u&&!h)return(0,r.jsxs)("div",{className:"container mx-auto px-4 py-8",children:[(0,r.jsxs)(et.Fc,{variant:"destructive",className:"rounded-lg",children:[(0,r.jsx)(et.XL,{children:"Error loading test data"}),(0,r.jsx)(et.TN,{children:u})]}),(0,r.jsxs)(i.$,{onClick:()=>s.push("/"),variant:"outline",className:"mt-4 rounded-lg",children:[(0,r.jsx)(ef,{className:"mr-2 h-4 w-4"})," Back"]})]});if(!h)return(0,r.jsxs)("div",{className:"container mx-auto px-4 py-8 text-center",children:[(0,r.jsxs)(et.Fc,{className:"rounded-lg",children:[(0,r.jsx)(et.XL,{children:"Test Not Found"}),(0,r.jsxs)(et.TN,{children:["The test with ID '",e,"' could not be found in the current report."]})]}),(0,r.jsxs)(i.$,{onClick:()=>s.push("/"),className:"mt-6 inline-flex items-center justify-center rounded-xl border bg-transparent px-4 py-2 text-sm font-medium text-muted-foreground shadow-sm transition-all duration-300 ease-in-out hover:-translate-y-0.5 hover:shadow-lg hover:bg-primary hover:text-primary-foreground hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",children:[(0,r.jsx)(ef,{className:"mr-2 h-4 w-4"})," Back to Dashboard"]})]});let U=function(e){if(!e)return"";let s=e.split(" > ");return s[s.length-1]||e}(h.name);return(0,r.jsxs)("div",{className:"container mx-auto px-4 py-8 space-y-6",children:[(0,r.jsxs)(i.$,{onClick:()=>s.push("/"),className:"mt-6 inline-flex items-center justify-center rounded-xl border bg-transparent px-4 py-2 text-sm font-medium text-muted-foreground shadow-sm transition-all duration-300 ease-in-out hover:-translate-y-0.5 hover:shadow-lg hover:bg-primary hover:text-primary-foreground hover:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",children:[(0,r.jsx)(ef,{className:"mr-2 h-4 w-4"})," Back to Dashboard"]}),(0,r.jsxs)(l.Zp,{className:"shadow-xl rounded-lg",children:[(0,r.jsxs)(l.aR,{children:[(0,r.jsxs)("div",{className:"flex items-start justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)(l.ZB,{className:"text-2xl font-headline text-primary flex items-center",title:h.name,children:[(0,r.jsx)(eG,{status:h.status}),(0,r.jsx)("span",{className:"ml-3",children:U})]}),h.suiteName&&(0,r.jsxs)(l.BT,{className:"mt-1 text-md",children:["From suite: ",h.suiteName]}),(0,r.jsxs)("p",{className:"text-sm text-muted-foreground mt-2",children:["Run Date:"," ","current"===D?c?(0,r.jsx)("span",{className:"text-muted-foreground",children:"Loading..."}):t?.run?.timestamp?(0,r.jsx)("span",{className:"font-medium",children:new Date(t.run.timestamp).toLocaleString()}):u&&!t?.run?.timestamp?(0,r.jsx)("span",{className:"text-destructive font-medium",children:"Error loading date"}):(0,r.jsx)("span",{className:"font-medium",children:"Not available"}):(0,r.jsx)("span",{className:"font-medium",children:new Date(D).toLocaleString()})]}),(0,r.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[(0,r.jsxs)("p",{children:["ID: ",h.id]}),h.browser&&(0,r.jsxs)("p",{children:["Browser: ",h.browser]})]})]}),(0,r.jsxs)("div",{className:"text-right flex-shrink-0",children:[(0,r.jsx)(eM.E,{variant:"outline",className:"capitalize text-sm px-3 py-1 rounded-full border",style:function(e){switch(e){case"passed":return{backgroundColor:"hsl(var(--chart-3))",color:"hsl(var(--primary-foreground))"};case"failed":case"timedOut":return{backgroundColor:"hsl(var(--destructive))",color:"hsl(var(--destructive-foreground))"};case"skipped":return{backgroundColor:"hsl(var(--accent))",color:"hsl(var(--accent-foreground))"};case"pending":return{backgroundColor:"hsl(var(--primary))",color:"hsl(var(--primary-foreground))"};default:return{backgroundColor:"hsl(var(--muted))",color:"hsl(var(--muted-foreground))"}}}(h.status),children:h.status}),(0,r.jsxs)("p",{className:"text-sm text-muted-foreground mt-1",children:["Duration: ",eX(h.duration)]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Retries: ",h.retries]}),h.tags&&h.tags.length>0&&(0,r.jsx)("div",{className:"mt-1 space-x-1",children:h.tags.map(e=>(0,r.jsx)(eM.E,{variant:"secondary",className:"text-xs rounded-full",children:e},e))})]})]}),(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsxs)(o.l6,{value:D,onValueChange:L,onOpenChange:e=>{e&&!F&&I()},children:[(0,r.jsx)(o.bq,{className:"w-full md:w-[350px] h-12 rounded-xl bg-card/50 border-2 border-transparent hover:border-primary/30 focus:ring-2 focus:ring-primary/50 focus:ring-offset-2 focus:ring-offset-background transition-colors duration-200 group",children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(en,{className:"h-5 w-5 text-muted-foreground transition-colors group-hover:text-primary"}),(0,r.jsx)(o.yv,{placeholder:"Switch to a past run"})]})}),(0,r.jsxs)(o.gC,{sideOffset:8,className:"bg-card/80 backdrop-blur-lg border border-border/50 rounded-xl shadow-2xl data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",children:[(0,r.jsx)(o.eb,{value:"current",className:"rounded-lg",children:"Current Run"}),j&&(0,r.jsx)(o.eb,{value:"loading",disabled:!0,className:"rounded-lg",children:"Loading history..."}),f.map(e=>(0,r.jsx)(o.eb,{value:e.date,className:"rounded-lg",children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:(0,J.cn)("h-2 w-2 rounded-full",B(e.status)),title:`Status: ${e.status}`}),(0,r.jsxs)("span",{className:"text-sm",children:[new Date(e.date).toLocaleString()," -"," ",(0,r.jsx)("span",{className:"font-medium capitalize",children:e.status})]})]})},e.date))]})]})})]}),(0,r.jsx)(l.Wu,{children:(0,r.jsxs)(q,{defaultValue:"steps",className:"w-full",onValueChange:e=>{"history"!==e||F||I()},children:[(0,r.jsxs)(Q,{className:(0,J.cn)("grid w-full mb-4 rounded-lg",W?"grid-cols-2 md:grid-cols-5":"grid-cols-2 md:grid-cols-4"),children:[(0,r.jsxs)(Y,{value:"steps",children:["Execution Steps (",h.steps?.length||0,")"]}),(0,r.jsxs)(Y,{value:"attachments",children:["Attachments (",K,")"]}),(0,r.jsxs)(Y,{value:"logs",children:[(0,r.jsx)(eh,{className:"h-4 w-4 mr-2"}),"Logs"]}),(0,r.jsx)(Y,{value:"history",children:"Test Run History"}),W&&(0,r.jsxs)(Y,{value:"ai-suggestions",children:[(0,r.jsx)(eg,{className:"h-4 w-4 mr-2"}),"AI Suggestions"]})]}),(0,r.jsxs)(ee,{value:"steps",className:"mt-4 p-1 md:p-4 border rounded-lg bg-card shadow-inner",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-3 px-3 md:px-0",children:"Test Execution Steps"}),h.errorMessage&&(0,r.jsxs)("div",{className:"mb-4 p-3 md:p-0",children:[(0,r.jsx)("h4",{className:"font-semibold text-md text-destructive mb-1",children:"Overall Test Error:"}),(0,r.jsx)("pre",{className:"bg-destructive/10 text-sm p-4 rounded-lg whitespace-pre-wrap break-all font-code overflow-x-auto",children:(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,J.cA)(h.errorMessage)}})})]}),h.steps&&h.steps.length>0?(0,r.jsx)(er.F,{className:"h-[600px] w-full",children:(0,r.jsx)("div",{className:"pr-4",children:h.steps.map((e,s)=>(0,r.jsx)(eD,{step:e},e.id||s))})}):(0,r.jsx)("p",{className:"text-muted-foreground p-3 md:p-0",children:"No detailed execution steps available for this test."})]}),(0,r.jsx)(ee,{value:"attachments",className:"mt-4 p-1 md:p-4 border rounded-lg bg-card shadow-inner",children:(0,r.jsxs)(q,{defaultValue:"sub-screenshots",className:"w-full",children:[(0,r.jsx)(er.F,{className:"w-full whitespace-nowrap rounded-lg",children:(0,r.jsxs)(Q,{className:"inline-grid w-max grid-flow-col mb-4 rounded-lg",children:[(0,r.jsxs)(Y,{value:"sub-screenshots",disabled:0===R.length,children:[(0,r.jsx)(ej,{className:"h-4 w-4 mr-2"}),"Screenshots (",R.length,")"]}),(0,r.jsxs)(Y,{value:"sub-video",disabled:0===$.length,children:[(0,r.jsx)(ev,{className:"h-4 w-4 mr-2"}),"Videos (",$.length,")"]}),(0,r.jsxs)(Y,{value:"sub-trace",disabled:!_,children:[(0,r.jsx)(eb,{className:"h-4 w-4 mr-2"}),"Trace ",_?"(1)":"(0)"]}),(0,r.jsxs)(Y,{value:"sub-html",disabled:0===H.length,children:[(0,r.jsx)(eu,{className:"h-4 w-4 mr-2"}),"HTML (",H.length,")"]}),(0,r.jsxs)(Y,{value:"sub-pdf",disabled:0===O.length,children:[(0,r.jsx)(eh,{className:"h-4 w-4 mr-2"}),"PDF (",O.length,")"]}),(0,r.jsxs)(Y,{value:"sub-json",disabled:0===V.length,children:[(0,r.jsx)(em,{className:"h-4 w-4 mr-2"}),"JSON (",V.length,")"]}),(0,r.jsxs)(Y,{value:"sub-text",disabled:0===G.length,children:[(0,r.jsx)(eh,{className:"h-4 w-4 mr-2"}),"Text/CSV (",G.length,")"]}),(0,r.jsxs)(Y,{value:"sub-other",disabled:0===X.length,children:[(0,r.jsx)(ep,{className:"h-4 w-4 mr-2"}),"Others (",X.length,")"]})]})}),(0,r.jsxs)(ee,{value:"sub-screenshots",className:"mt-4",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"Screenshots"}),R.length>0?(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:R.map((e,s)=>{let t=(0,J.OX)(e.path);return"#"===t?null:(0,r.jsxs)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"relative aspect-video rounded-lg overflow-hidden group border hover:border-primary transition-all shadow-md hover:shadow-lg",children:[(0,r.jsx)(eT.default,{src:t,alt:e.name||`Screenshot ${s+1}`,fill:!0,style:{objectFit:"cover"},className:"group-hover:scale-105 transition-transform duration-300","data-ai-hint":e["data-ai-hint"]||"test screenshot"}),(0,r.jsx)("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center p-2",children:(0,r.jsx)("p",{className:"text-white text-xs text-center break-all",children:e.name||`Screenshot ${s+1}`})})]},`img-preview-${s}`)})}):(0,r.jsx)("p",{className:"text-muted-foreground",children:"No screenshots available for this test."})]}),(0,r.jsxs)(ee,{value:"sub-video",className:"mt-4",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"Video Recording(s)"}),(0,r.jsx)("div",{className:"space-y-4",children:$.length>0?$.map((e,s)=>(0,r.jsxs)("div",{className:"p-4 border rounded-lg bg-muted/30 shadow-sm flex items-center justify-between",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-foreground truncate",title:e.name,children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(i.$,{asChild:!0,variant:"ghost",size:"sm",children:(0,r.jsx)("a",{href:(0,J.OX)(e.path),target:"_blank",rel:"noopener noreferrer",children:"View"})}),(0,r.jsx)(i.$,{asChild:!0,variant:"outline",size:"sm",children:(0,r.jsxs)("a",{href:(0,J.OX)(e.path),download:e.name,children:[(0,r.jsx)(ey,{className:"h-4 w-4 mr-2"}),"Download"]})})]})]},`video-${s}`)):(0,r.jsxs)(et.Fc,{className:"rounded-lg",children:[(0,r.jsx)(ec.A,{className:"h-4 w-4"}),(0,r.jsx)(et.XL,{children:"No Videos Available"}),(0,r.jsx)(et.TN,{children:"There is no video recording associated with this test run."})]})})]}),(0,r.jsxs)(ee,{value:"sub-trace",className:"mt-4",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"Trace File"}),_?(0,r.jsxs)("div",{className:"p-4 border rounded-lg bg-muted/30 space-y-3 shadow-sm",children:[(0,r.jsxs)("a",{href:(0,J.OX)(_.path),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-primary hover:underline text-base",download:_.name,children:[(0,r.jsx)(ey,{className:"h-5 w-5 mr-2"})," Download Trace File (",_.name,")"]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Path: ",_.path]}),(0,r.jsxs)(et.Fc,{className:"rounded-lg",children:[(0,r.jsx)(ec.A,{className:"h-4 w-4"}),(0,r.jsx)(et.XL,{children:"Using Trace Files"}),(0,r.jsxs)(et.TN,{children:["Trace files (.zip) can be viewed using the Playwright CLI:"," ",(0,r.jsx)("code",{className:"bg-muted px-1 py-0.5 rounded-sm",children:"npx playwright show-trace /path/to/your/trace.zip"}),". Or by uploading them to"," ",(0,r.jsx)("a",{href:"https://trace.playwright.dev/",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"trace.playwright.dev"}),"."]})]})]}):(0,r.jsxs)(et.Fc,{className:"rounded-lg",children:[(0,r.jsx)(ec.A,{className:"h-4 w-4"}),(0,r.jsx)(et.XL,{children:"No Trace File Available"}),(0,r.jsx)(et.TN,{children:"There is no Playwright trace file associated with this test run."})]})]}),[{value:"sub-html",title:"HTML Files",attachments:H},{value:"sub-pdf",title:"PDF Documents",attachments:O},{value:"sub-json",title:"JSON Files",attachments:V},{value:"sub-text",title:"Text & CSV Files",attachments:G},{value:"sub-other",title:"Other Files",attachments:X}].map(e=>(0,r.jsxs)(ee,{value:e.value,className:"mt-4",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-foreground mb-4",children:e.title}),(0,r.jsx)("div",{className:"space-y-3",children:e.attachments.length>0?e.attachments.map((e,s)=>(0,r.jsxs)("div",{className:"p-3 border rounded-lg bg-muted/30 shadow-sm flex items-center justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 truncate",children:[(0,r.jsx)(eK,{contentType:e.contentType}),(0,r.jsxs)("div",{className:"truncate",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-foreground truncate",title:e.name,children:e.name}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:e.contentType})]})]}),(0,r.jsxs)("div",{className:"flex items-center flex-shrink-0 gap-2",children:[(0,r.jsx)(i.$,{asChild:!0,variant:"ghost",size:"sm",children:(0,r.jsx)("a",{href:(0,J.OX)(e.path),target:"_blank",rel:"noopener noreferrer",children:"View"})}),(0,r.jsx)(i.$,{asChild:!0,variant:"outline",size:"sm",children:(0,r.jsxs)("a",{href:(0,J.OX)(e.path),download:e.name,children:[(0,r.jsx)(ey,{className:"h-4 w-4 mr-2"}),"Download"]})})]})]},s)):(0,r.jsxs)(et.Fc,{className:"rounded-lg",children:[(0,r.jsx)(ec.A,{className:"h-4 w-4"}),(0,r.jsx)(et.XL,{children:"No Files Available"}),(0,r.jsx)(et.TN,{children:"No attachments of this type were found for this test."})]})})]},e.value))]})}),(0,r.jsxs)(ee,{value:"logs",className:"mt-4 p-4 border rounded-lg bg-card space-y-6 shadow-inner",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:"text-lg font-semibold text-foreground mb-3 flex items-center",children:[(0,r.jsx)(eN.A,{className:"h-5 w-5 mr-2 text-primary"}),"Console Logs / Standard Output"]}),(0,r.jsx)(er.F,{className:"h-48 w-full rounded-lg border p-3 bg-muted/30 shadow-sm",children:(0,r.jsx)("pre",{className:"text-sm whitespace-pre-wrap break-words font-code",children:(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,J.cA)(h.stdout&&Array.isArray(h.stdout)&&h.stdout.length>0?h.stdout.join("\n"):"No standard output logs captured for this test.")}})})})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:"text-lg font-semibold text-foreground mb-3 flex items-center",children:[(0,r.jsx)(eo.A,{className:"h-5 w-5 mr-2 text-destructive"}),"Error Messages / Standard Error"]}),(0,r.jsx)(er.F,{className:"h-48 w-full rounded-lg border bg-destructive/5 shadow-sm",children:(0,r.jsx)("pre",{className:"text-sm p-3 whitespace-pre-wrap break-all font-code",children:(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,J.cA)(h.errorMessage||"No errors captured for this test.")}})})})]}),h.snippet&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:"text-lg font-semibold text-foreground mb-3 flex items-center",children:[(0,r.jsx)(eu,{className:"h-5 w-5 mr-2 text-primary"}),"Test Case Snippet"]}),(0,r.jsx)(er.F,{className:"h-48 w-full rounded-lg border p-3 bg-muted/30 shadow-sm",children:(0,r.jsx)("pre",{className:"text-sm whitespace-pre-wrap break-words font-code",children:(0,r.jsx)("span",{dangerouslySetInnerHTML:{__html:(0,J.cA)(h.snippet)}})})})]})]}),(0,r.jsxs)(ee,{value:"history",className:"mt-4 p-4 border rounded-lg bg-card shadow-inner",children:[(0,r.jsx)("div",{className:"flex justify-between items-center mb-3",children:(0,r.jsxs)("h3",{className:"text-lg font-semibold text-foreground flex items-center",children:[(0,r.jsx)(ew,{className:"h-5 w-5 mr-2 text-primary"}),"Individual Test Run History"]})}),j&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(es.E,{className:"h-6 w-3/4 rounded-md"}),(0,r.jsx)(es.E,{className:"h-64 w-full rounded-lg"})]}),b&&!j&&(0,r.jsxs)(et.Fc,{variant:"destructive",className:"rounded-lg",children:[(0,r.jsx)(eo.A,{className:"h-4 w-4"}),(0,r.jsx)(et.XL,{children:"Error Loading Test History"}),(0,r.jsx)(et.TN,{children:b})]}),!j&&!b&&F&&0===f.length&&(0,r.jsxs)(et.Fc,{className:"rounded-lg",children:[(0,r.jsx)(ec.A,{className:"h-4 w-4"}),(0,r.jsx)(et.XL,{children:"No Historical Data"}),(0,r.jsxs)(et.TN,{children:["No historical run data found for this specific test (ID:"," ",e,") in this suite."]})]}),!j&&!b&&f.length>0&&(0,r.jsx)("div",{ref:N,className:"w-full h-[300px] bg-card p-4 rounded-lg shadow-inner",children:(0,r.jsx)(eP.u,{width:"100%",height:"100%",children:(0,r.jsxs)(eI.b,{data:[...f].reverse(),margin:{top:5,right:20,left:-20,bottom:5},children:[(0,r.jsx)(eR.d,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),(0,r.jsx)(e$.W,{dataKey:"date",tickFormatter:e=>new Date(e).toLocaleDateString("en-CA",{month:"short",day:"numeric"}),stroke:"hsl(var(--muted-foreground))",tick:{fontSize:10},angle:-30,textAnchor:"end",height:40}),(0,r.jsx)(e_.h,{tickFormatter:e=>eX(e),stroke:"hsl(var(--muted-foreground))",tick:{fontSize:10},width:80}),(0,r.jsx)(ez.m,{content:(0,r.jsx)(eV,{})}),(0,r.jsx)(eH.s,{wrapperStyle:{fontSize:"12px"}}),(0,r.jsx)(eO.N,{type:"monotone",dataKey:"duration",name:"Duration",stroke:"hsl(var(--primary))",strokeWidth:2,dot:(0,r.jsx)(eq,{}),activeDot:{r:7}})]})})})]}),W&&(0,r.jsx)(ee,{value:"ai-suggestions",className:"mt-4 p-4 border rounded-lg bg-card shadow-inner",children:(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center text-center p-2 md:p-6",children:[(0,r.jsxs)("h3",{className:"text-lg font-semibold text-foreground mb-3 flex items-center",children:[(0,r.jsx)(eg,{className:"h-5 w-5 mr-2 text-primary"}),"AI-Powered Failure Analysis"]}),!(A||w||M)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-muted-foreground text-sm mb-6 max-w-md",children:"Get suggestions from AI to help diagnose the root cause of this test failure and find potential solutions."}),(0,r.jsxs)(i.$,{onClick:P,disabled:A,children:[(0,r.jsx)(eg,{className:"h-4 w-4 mr-2"}),"Generate Suggestion"]})]}),A&&(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-10",children:[(0,r.jsx)(eg,{className:"h-8 w-8 text-primary animate-pulse mb-4"}),(0,r.jsx)("p",{className:"text-muted-foreground",children:"Generating suggestion... Please wait."})]}),M&&(0,r.jsxs)("div",{className:"w-full text-left",children:[(0,r.jsxs)(et.Fc,{variant:"destructive",children:[(0,r.jsx)(et.XL,{children:"Error Generating Suggestion"}),(0,r.jsx)(et.TN,{children:M})]}),(0,r.jsxs)(i.$,{onClick:P,variant:"outline",size:"sm",className:"mt-4",children:[(0,r.jsx)(eg,{className:"h-4 w-4 mr-2"}),"Try Again"]})]}),w&&(0,r.jsxs)("div",{className:"text-left w-full mt-6 space-y-6",children:[(0,r.jsxs)(et.Fc,{variant:"default",className:"border-primary/30 bg-primary/5",children:[(0,r.jsx)(ek,{className:"h-5 w-5 text-primary"}),(0,r.jsx)(et.XL,{className:"text-primary font-semibold",children:"Root Cause Analysis"}),(0,r.jsx)(et.TN,{className:"text-primary/90",children:w.rootCause||"No root cause analysis provided."})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-semibold text-foreground mb-2",children:"Affected Tests:"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:w.affectedTests?.map(e=>r.jsx(eM.E,{variant:"secondary",children:e},e))||(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"N/A"})})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h4",{className:"font-semibold text-foreground mb-3 flex items-center",children:[(0,r.jsx)(eA,{className:"h-4 w-4 mr-2"}),"Suggested Fixes"]}),(0,r.jsxs)("div",{className:"space-y-4",children:[w.suggestedFixes?.map((e,s)=>r.jsxs(l.Zp,{className:"bg-card/50 shadow-md",children:[r.jsx(l.aR,{children:r.jsxs(l.ZB,{className:"text-base",children:["Suggestion #",s+1]})}),r.jsxs(l.Wu,{children:[r.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e.description}),e.codeSnippet&&r.jsxs("div",{children:[r.jsxs("h5",{className:"text-xs font-semibold text-foreground mb-1 flex items-center",children:[r.jsx(eu,{className:"h-3 w-3 mr-1.5"}),"Code Snippet:"]}),r.jsx("pre",{className:"bg-muted text-sm p-3 rounded-md whitespace-pre-wrap font-code overflow-x-auto",children:r.jsx("code",{children:e.codeSnippet})})]})]})]},s)),(!w.suggestedFixes||0===w.suggestedFixes.length)&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"No specific fixes were suggested."})]})]}),(0,r.jsxs)(i.$,{onClick:P,variant:"outline",size:"sm",className:"mt-4",children:[(0,r.jsx)(eg,{className:"h-4 w-4 mr-2"}),"Regenerate Suggestion"]})]})]})})]})})]})]})}},71990:(e,s,t)=>{"use strict";t.r(s),t.d(s,{GlobalError:()=>l.a,__next_app__:()=>u,pages:()=>c,routeModule:()=>h,tree:()=>d});var r=t(65239),a=t(48088),n=t(88170),l=t.n(n),i=t(30893),o={};for(let e in i)0>["default","tree","pages","GlobalError","__next_app__","routeModule"].indexOf(e)&&(o[e]=()=>i[e]);t.d(s,o);let d={children:["",{children:["test",{children:["[testId]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(t.bind(t,93161)),"/Users/administrator/playwright-pulse-dashboard/src/app/test/[testId]/page.tsx"]}]},{}]},{}]},{layout:[()=>Promise.resolve().then(t.bind(t,94431)),"/Users/administrator/playwright-pulse-dashboard/src/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(t.t.bind(t,57398,23)),"next/dist/client/components/not-found-error"],forbidden:[()=>Promise.resolve().then(t.t.bind(t,89999,23)),"next/dist/client/components/forbidden-error"],unauthorized:[()=>Promise.resolve().then(t.t.bind(t,65284,23)),"next/dist/client/components/unauthorized-error"]}]}.children,c=["/Users/administrator/playwright-pulse-dashboard/src/app/test/[testId]/page.tsx"],u={require:t,loadChunk:()=>Promise.resolve()},h=new r.AppPageRouteModule({definition:{kind:a.RouteKind.APP_PAGE,page:"/test/[testId]/page",pathname:"/test/[testId]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:d}})},79748:e=>{"use strict";e.exports=require("fs/promises")},90405:(e,s,t)=>{Promise.resolve().then(t.bind(t,17947))},93161:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>l,metadata:()=>n});var r=t(37413),a=t(17947);let n={title:"Test Details - Pulse Dashboard",description:"Detailed view of a specific test run."};async function l({params:e}){let{testId:s}=await e;return(0,r.jsx)(a.TestDetailsClientPage,{testId:s})}}};var s=require("../../../webpack-runtime.js");s.C(e);var t=e=>s(s.s=e),r=s.X(0,[447,724,765,126,201,967],()=>t(71990));module.exports=r})();